package com.jason.bean;

import java.sql.Timestamp;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;

import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Entity(name="user_info")
@Data
@AllArgsConstructor
@NoArgsConstructor
public class UserInfo {

	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private Integer id;
	@Column(name="nike_name",length=50,nullable=false)
	private String nikeName;
	@Column(name="account",unique=true,length=50,nullable=false)
	private String account;
	@Column(name="password",length=64,nullable=false)
	private String password;
	@CreationTimestamp
	@Column(name="create_time",nullable=false)
	private Timestamp createTime;
	@UpdateTimestamp
	@Column(name="update_time")
	private Timestamp updateTime;
	@Column(name="status",length=2,nullable=false)
	private Integer status;
	
	
	@ManyToMany(cascade=CascadeType.ALL)
	@JoinTable(name="user_role",joinColumns=@JoinColumn(name="id"),inverseJoinColumns=@JoinColumn(name="user_id"))
	private List<Role> roles;
}
